home *** CD-ROM | disk | FTP | other *** search
- """
- /***************************************************************************
-
- Author :Charles B. Cosse
-
- Email :ccosse@asymptopia.com
-
-
- Copyright :(C) 2002,2003 Asymptopia Software.
-
- ***************************************************************************/
- /***************************************************************************
- myutil.py
-
- ***************************************************************************/
-
- /***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. (Please note that if you use this *
- * code you must give credit by including the Author and Copyright *
- * info at the top of this file). *
- ***************************************************************************/
- """
-
- import pygame,os,sys
- from pygame.locals import *
-
- #get path to site-packages:
- try:
- for sitepkgdir in sys.path:
- if sitepkgdir[-13:]=='site-packages':break
- except:pass
-
-
- def load_image(name, colorkey=None):
- fullname = os.path.join(sitepkgdir,name)
- try:
- image = pygame.image.load(fullname)
- except pygame.error, message:
- print 'Cannot load image:', name
- raise SystemExit, message
- image = image.convert()
- if colorkey is not None:
- if colorkey is -1:
- colorkey = image.get_at((0,0))
- image.set_colorkey(colorkey, RLEACCEL)
- return image, image.get_rect()
-
- def load_sound(name):
- class NoneSound:
- def play(self): pass
- if not pygame.mixer or not pygame.mixer.get_init():
- return NoneSound()
- fullname = os.path.join(sitepkgdir, name)
- try:
- sound = pygame.mixer.Sound(fullname)
- except pygame.error, message:
- print 'Cannot load sound:', fullname
- raise SystemExit, message
- return sound
-
-